package com.justech.eat.util;

import com.github.pagehelper.PageInfo;
import com.justech.common.vo.PageDto;
import com.justech.common.vo.TablePage;

import java.util.List;

public class PageBuilder {
    public static <T> PageDto<T> build(List<T> list, Integer cur, Integer size, Long total) {
        PageDto<T> pageDto = new PageDto<>();
        pageDto.setTablePage(new TablePage(cur, size, total));
        pageDto.setList(list);
        return pageDto;
    }

    public static <T> PageDto<T> build(PageInfo<T> pageInfo) {
        return build(pageInfo.getList(), pageInfo.getPageNum(), pageInfo.getSize(), pageInfo.getTotal());
    }
}

